/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Controller;

import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author subx
 */
public class Config {

    private static Config instance = null;

    private List<String> info;

    private int nodes;
    private int edges;

    private int totalWeight  = 0;
    private int totalDist = 0;

    private Graph graph;

    
    /**
     * Construtor padrão.
     */
    private Config() {
        graph = new Graph();
        info = new LinkedList<String>();
        
        info.add("");
        info.add("");
        info.add("");
        info.add("");
        info.add("");
    }

    public static Config getInstance(){
        if(instance == null)
            instance = new Config();

        return instance;
    }

    public void dispose(){
        instance = null;
    }

    public boolean wasLoaded() {
        return graph.isEmpty();
    }
    
    /**
     * Get the value of info
     *
     * @return the value of info
     */
    public List<String> getInfo() {
        if(info == null)
            info = new LinkedList();
        
        return info;
    }

    /**
     * Set the value of info
     *
     * @param info new value of info
     */
    public void setInfo(List<String> info) {
        this.info = info;
    }

    /**
     * Get the value of info at specified index
     *
     * @param index
     * @return the value of info at specified index
     */
    public String getInfo(int index) {
        if(!getInfo().isEmpty())
            return getInfo().get(index);
        else
            return null;
    }

    /**
     * Set the value of info at specified index.
     *
     * @param index
     * @param newInfo new value of info at specified index
     */
    public void setInfo(int index, String newInfo) {
        this.getInfo().set(index, newInfo);
    }

    public int getEdges() {
        return edges;
    }

    public void setEdges(int edges) {
        this.edges = edges;
    }

    public int getNodes() {
        return nodes;
    }

    public void setNodes(int nodes) {
        this.nodes = nodes;
    }

    public int getTotalDist() {
        return totalDist;
    }

    public void setTotalDist(int totalDist) {
        this.totalDist = totalDist;
    }

    public int getTotalWeight() {
        return totalWeight;
    }

    public void setTotalWeight(int totalWeight) {
        this.totalWeight = totalWeight;
    }

    public Graph getGraph() {
        return graph;
    }

    public void setNode(int id, int x, int y, int weight){
        getGraph().setNode(id, x, y, weight);
    }

    public void setEdge(int id, int ide, int weight){
        getGraph().setEdge(id, ide, weight);
    }

    /**
     * Imprime conteúdo do atributo infos de Config.
     */
    public void printHead(){
        for(String s : info)
            System.out.println("Info: " + s);
    }
}
